{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "source": [
    "import numpy as np\n",
    "from simulation_data import *\n",
    "from scipy import special"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "source": [
    "n = 500\n",
    "i = 30\n",
    "k = 10\n",
    "s = 0.1\n",
    "g = 0.1\n",
    "student_mean = [0,0]\n",
    "student_cov = [[1,0.25],[0.25,0.25]]\n",
    "lambda_k = np.repeat(1.5,k)\n",
    "lambda_0 = np.linspace(-1,0.5,k)\n",
    "tau_beta = np.random.uniform(0.6,0.6+0.3,k)\n",
    "beta_i = special.logit(g)\n",
    "delta_i = special.logit(1 - s) - special.logit(g)\n",
    "item_mean = [beta_i,delta_i,4]\n",
    "item_cov = [[1,-0.8,-0.25],\n",
    "            [-0.8,1,0.15],\n",
    "            [-0.25,0.15,0.25]]\n",
    "omega = [1,5]\n",
    "rg_param,cheat_param = [1,5],[0.05,0.15]\n",
    "pre_knownledge_index = np.random.randint(0,i,4)"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "source": [
    "pre_knownledge_index"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "array([ 8,  4, 15, 25])"
      ]
     },
     "metadata": {},
     "execution_count": 3
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "source": [
    "\n",
    "student = CdmStudentParam(n,k,student_mean,\n",
    "                        student_cov,lambda_k,lambda_0,\n",
    "                        np.array(tau_beta))\n",
    "student.get()\n",
    "item = CdmBaseModel(i,k,item_mean,item_cov,omega)\n",
    "item.get()\n",
    "compute_model = CdmJointModelCompute(i,k,n,item,student)\n",
    "compute_model.get()\n",
    "abbrant = AberrantResponse(n,i,student_class=student,\n",
    "                                item_class=item,\n",
    "                                compute_class=compute_model)\n",
    "abbrant.rg_flag = np.random.binomial(1,0.2,(n,i))\n",
    "abbrant.flag_preknowledge(pre_knownledge_index,0.1)\n",
    "abbrant.get(rg_param,cheat_param)"
   ],
   "outputs": [
    {
     "output_type": "error",
     "ename": "TypeError",
     "evalue": "__init__() takes 7 positional arguments but 8 were given",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-4-6ff3a8da2b29>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m student = CdmStudentParam(n,k,student_mean,\n\u001b[0m\u001b[1;32m      2\u001b[0m                         \u001b[0mstudent_cov\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlambda_k\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mlambda_0\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m                         np.array(tau_beta))\n\u001b[1;32m      4\u001b[0m \u001b[0mstudent\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0mitem\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mCdmBaseModel\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mitem_mean\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mitem_cov\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0momega\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mTypeError\u001b[0m: __init__() takes 7 positional arguments but 8 were given"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "\n"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "data_key = [\"student_cov\",\"lambda_0\",\"lambda_k\",\n",
    "            \"tau_beta\",\"item_mean\",\"item_cov\",\n",
    "            \"omega\",\"xi\",\"ho_theta\",\"ho_tau\",\"att\",\n",
    "            \"specific_tau\",\"beta_i\",\"delta_i\",\n",
    "            \"flag\",\"pre_knowledge_flag\"]\n",
    "t_data_list = [student_cov,lambda_0,lambda_k,\n",
    "            tau_beta,item_mean,item_cov,\n",
    "            item.alpha,item.xi,student.ho_theta,student.ho_tau,\n",
    "            student.specific_att,student.specific_tau,item.beta_i,item.delta_i,\n",
    "            abbrant.rg_flag+abbrant.preknowledge_flag,abbrant.preknowledge_flag]\n",
    "infer_data_key = [\"person_cov\",\"lambda_0\",\"lambda_k\",\n",
    "            \"tau_beta\",\"item_mu\",\"item_cov\",\n",
    "            \"ommega\",\"xi\",\"ho_theta\",\"ho_tau\",\n",
    "            \"att\",\"tau\",\"beta_i\",\"delta_i\",\n",
    "            \"flag\",\"pre_knowledge_flag\"]\n",
    "col = [i for i in data_key if i not in [\"tau_beta\",\"specific_tau\"]]"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "sns.histplot(np.log(compute_model.rt.flatten()))"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "<AxesSubplot:ylabel='Count'>"
      ]
     },
     "metadata": {},
     "execution_count": 6
    },
    {
     "output_type": "display_data",
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAD4CAYAAAAD6PrjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEA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2kIeATwL6SYzIzGyiVaT6KiLclfRr4c5pDUh+MiL8qOawqGbgmM/yaB8kgvu5KvubKdDSbmVn5qtR8ZGZmJXNSMDOzjJNCj5D07yUdlfR0etxSdkxFkbRZ0o8lHZG0q+x4ukXSS5KeTf+/B8uOpyiSHpR0QtLhXNkqSY9LeiE9j5UZ41K7yGuu5HvaSaG33B0R16fHY2UHU4Tccic3A+8FPinpveVG1VUfSf+/lRu/voS+BGyeVbYLOBARG4ED6byffIkLXzNU8D3tpGBVky13EhFvAa3lTqxPRMT3gFdnFW8B9qTjPcDWbsZUtIu85kpyUugtn5b0TKqK9lX1Omc1MJU7n05lgyCAb0l6Ki3nMkjGI+JYOn4ZGC8zmC6q3HvaSaFCJP2FpMNtHluA+4C/A1wPHAP+c5mxWiE+HBE30Gw62ynpl8sOqAzRHCc/CGPlK/merszkNYOI+Ied3Cfpj4FvFhxOWQZ2uZOIOJqeT0h6hGZT2vfKjaprjkuaiIhjkiaAvt/rNSKOt46r9J52TaFHpDdKy68Bhy92b48byOVOJK2UdGXrGPgV+vf/uJ19wLZ0vA14tMRYuqKq72nXFHrHf5B0Pc1q9UvAb5UaTUEGeLmTceARSdB8X/5pROwvN6RiSPoKcBNwjaRp4PPAXcDDkrYDdeDW8iJcehd5zTdV8T3tZS7MzCzj5iMzM8s4KZiZWcZJwczMMk4KZmaWcVIwM7OMk4KZmWWcFMzMLPP/AfSViQxdObSBAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     }
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "# sns.histplot(compute_model.rt.flatten())"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "\n",
    "import pyjags \n",
    "from param_estimate_code import detect_2_abberant_model\n",
    "input_data = {\n",
    "    \"I\":i,\n",
    "    \"N\":n,\n",
    "    \"K\":k,\n",
    "    \"Q\":compute_model.Q,\n",
    "    \"Y\":abbrant.ra,\n",
    "    \"logT\":np.log(abbrant.rt),\n",
    "    \"R1\":np.eye(3),\n",
    "    \"R2\":np.eye(2)\n",
    "}\n",
    "\n",
    "def model_sampler(model_code,return_vars):\n",
    "  model = pyjags.Model(code=model_code,\n",
    "                     data=input_data,\n",
    "                     chains=2,\n",
    "                     progress_bar=True,\n",
    "                     threads=4,\n",
    "                      generate_data=True,\n",
    "                      chains_per_thread=1,\n",
    "                    adapt=False\n",
    "                     )\n",
    "  print(\"burning.......\")\n",
    "  model.sample(iterations=2000,vars=[],thin=5000)\n",
    "\n",
    "  print(\"sampling.......\")\n",
    "  jags_tarce_posterior = model.sample(iterations=2000,vars=return_vars,thin=1)\n",
    "  return jags_tarce_posterior\n",
    "trace= model_sampler(detect_2_abberant_model,infer_data_key)"
   ],
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "burning.......\n",
      "sampling: iterations 12 of 4000, elapsed 0:00:06, remaining 0:33:08\n",
      "sampling: iterations 47 of 4000, elapsed 0:00:15, remaining 0:21:16\n",
      "sampling: iterations 81 of 4000, elapsed 0:00:25, remaining 0:19:46\n",
      "sampling: iterations 97 of 4000, elapsed 0:00:30, remaining 0:19:48\n",
      "sampling: iterations 114 of 4000, elapsed 0:00:35, remaining 0:19:41\n",
      "sampling: iterations 140 of 4000, elapsed 0:00:40, remaining 0:18:25\n",
      "sampling: iterations 157 of 4000, elapsed 0:00:45, remaining 0:18:24\n",
      "sampling: iterations 174 of 4000, elapsed 0:00:50, remaining 0:18:22\n",
      "sampling: iterations 191 of 4000, elapsed 0:00:55, remaining 0:18:22\n",
      "sampling: iterations 208 of 4000, elapsed 0:01:00, remaining 0:18:22\n",
      "sampling: iterations 233 of 4000, elapsed 0:01:09, remaining 0:18:38\n",
      "sampling: iterations 259 of 4000, elapsed 0:01:15, remaining 0:18:01\n",
      "sampling: iterations 284 of 4000, elapsed 0:01:23, remaining 0:18:12\n",
      "sampling: iterations 310 of 4000, elapsed 0:01:29, remaining 0:17:44\n",
      "sampling: iterations 335 of 4000, elapsed 0:01:38, remaining 0:17:50\n",
      "sampling: iterations 352 of 4000, elapsed 0:01:43, remaining 0:17:49\n",
      "sampling: iterations 369 of 4000, elapsed 0:01:48, remaining 0:17:46\n",
      "sampling: iterations 386 of 4000, elapsed 0:01:54, remaining 0:17:44\n",
      "sampling: iterations 403 of 4000, elapsed 0:01:59, remaining 0:17:40\n",
      "sampling: iterations 429 of 4000, elapsed 0:02:05, remaining 0:17:23\n",
      "sampling: iterations 454 of 4000, elapsed 0:02:13, remaining 0:17:21\n",
      "sampling: iterations 480 of 4000, elapsed 0:02:20, remaining 0:17:05\n",
      "sampling: iterations 505 of 4000, elapsed 0:02:28, remaining 0:17:04\n",
      "sampling: iterations 531 of 4000, elapsed 0:02:34, remaining 0:16:49\n",
      "sampling: iterations 548 of 4000, elapsed 0:02:40, remaining 0:16:46\n",
      "sampling: iterations 565 of 4000, elapsed 0:02:45, remaining 0:16:43\n",
      "sampling: iterations 582 of 4000, elapsed 0:02:50, remaining 0:16:41\n",
      "sampling: iterations 599 of 4000, elapsed 0:02:55, remaining 0:16:36\n",
      "sampling: iterations 624 of 4000, elapsed 0:03:03, remaining 0:16:31\n",
      "sampling: iterations 650 of 4000, elapsed 0:03:10, remaining 0:16:20\n",
      "sampling: iterations 675 of 4000, elapsed 0:03:18, remaining 0:16:13\n",
      "sampling: iterations 701 of 4000, elapsed 0:03:25, remaining 0:16:02\n",
      "sampling: iterations 726 of 4000, elapsed 0:03:32, remaining 0:15:55\n",
      "sampling: iterations 743 of 4000, elapsed 0:03:37, remaining 0:15:51\n",
      "sampling: iterations 760 of 4000, elapsed 0:03:42, remaining 0:15:48\n",
      "sampling: iterations 777 of 4000, elapsed 0:03:48, remaining 0:15:44\n",
      "sampling: iterations 794 of 4000, elapsed 0:03:53, remaining 0:15:39\n",
      "sampling: iterations 820 of 4000, elapsed 0:04:01, remaining 0:15:33\n",
      "sampling: iterations 845 of 4000, elapsed 0:04:07, remaining 0:15:22\n",
      "sampling: iterations 871 of 4000, elapsed 0:04:15, remaining 0:15:17\n",
      "sampling: iterations 896 of 4000, elapsed 0:04:22, remaining 0:15:06\n",
      "sampling: iterations 922 of 4000, elapsed 0:04:30, remaining 0:15:01\n",
      "sampling: iterations 939 of 4000, elapsed 0:04:35, remaining 0:14:57\n",
      "sampling: iterations 956 of 4000, elapsed 0:04:41, remaining 0:14:54\n",
      "sampling: iterations 973 of 4000, elapsed 0:04:46, remaining 0:14:50\n",
      "sampling: iterations 990 of 4000, elapsed 0:04:51, remaining 0:14:45\n",
      "sampling: iterations 1015 of 4000, elapsed 0:04:57, remaining 0:14:34\n",
      "sampling: iterations 1041 of 4000, elapsed 0:05:06, remaining 0:14:29\n",
      "sampling: iterations 1066 of 4000, elapsed 0:05:12, remaining 0:14:19\n",
      "sampling: iterations 1092 of 4000, elapsed 0:05:20, remaining 0:14:13\n",
      "sampling: iterations 1117 of 4000, elapsed 0:05:27, remaining 0:14:03\n",
      "sampling: iterations 1134 of 4000, elapsed 0:05:32, remaining 0:14:00\n",
      "sampling: iterations 1151 of 4000, elapsed 0:05:38, remaining 0:13:56\n",
      "sampling: iterations 1175 of 4000, elapsed 0:05:45, remaining 0:13:50\n",
      "sampling: iterations 1199 of 4000, elapsed 0:05:53, remaining 0:13:44\n",
      "sampling: iterations 1215 of 4000, elapsed 0:05:58, remaining 0:13:41\n",
      "sampling: iterations 1231 of 4000, elapsed 0:06:03, remaining 0:13:37\n",
      "sampling: iterations 1263 of 4000, elapsed 0:06:12, remaining 0:13:27\n",
      "sampling: iterations 1287 of 4000, elapsed 0:06:18, remaining 0:13:16\n",
      "sampling: iterations 1311 of 4000, elapsed 0:06:25, remaining 0:13:10\n",
      "sampling: iterations 1336 of 4000, elapsed 0:06:31, remaining 0:13:01\n",
      "sampling: iterations 1362 of 4000, elapsed 0:06:39, remaining 0:12:53\n",
      "sampling: iterations 1387 of 4000, elapsed 0:06:46, remaining 0:12:45\n",
      "sampling: iterations 1404 of 4000, elapsed 0:06:51, remaining 0:12:40\n",
      "sampling: iterations 1430 of 4000, elapsed 0:06:57, remaining 0:12:30\n",
      "sampling: iterations 1456 of 4000, elapsed 0:07:05, remaining 0:12:23\n",
      "sampling: iterations 1490 of 4000, elapsed 0:07:13, remaining 0:12:09\n",
      "sampling: iterations 1515 of 4000, elapsed 0:07:18, remaining 0:11:59\n",
      "sampling: iterations 1541 of 4000, elapsed 0:07:24, remaining 0:11:48\n",
      "sampling: iterations 1567 of 4000, elapsed 0:07:31, remaining 0:11:40\n",
      "sampling: iterations 1592 of 4000, elapsed 0:07:36, remaining 0:11:30\n",
      "sampling: iterations 1627 of 4000, elapsed 0:07:45, remaining 0:11:18\n",
      "sampling: iterations 1652 of 4000, elapsed 0:07:50, remaining 0:11:08\n",
      "sampling: iterations 1678 of 4000, elapsed 0:07:56, remaining 0:10:58\n",
      "sampling: iterations 1704 of 4000, elapsed 0:08:02, remaining 0:10:50\n",
      "sampling: iterations 1729 of 4000, elapsed 0:08:08, remaining 0:10:41\n",
      "sampling: iterations 1764 of 4000, elapsed 0:08:15, remaining 0:10:28\n",
      "sampling: iterations 1798 of 4000, elapsed 0:08:22, remaining 0:10:14\n",
      "sampling: iterations 1824 of 4000, elapsed 0:08:28, remaining 0:10:06\n",
      "sampling: iterations 1858 of 4000, elapsed 0:08:35, remaining 0:09:53\n",
      "sampling: iterations 1883 of 4000, elapsed 0:08:41, remaining 0:09:46\n",
      "sampling: iterations 1918 of 4000, elapsed 0:08:49, remaining 0:09:34\n",
      "sampling: iterations 1952 of 4000, elapsed 0:08:56, remaining 0:09:22\n",
      "sampling: iterations 1986 of 4000, elapsed 0:09:02, remaining 0:09:10\n",
      "sampling: iterations 2011 of 4000, elapsed 0:09:07, remaining 0:09:01\n",
      "sampling: iterations 2046 of 4000, elapsed 0:09:14, remaining 0:08:49\n",
      "sampling: iterations 2074 of 4000, elapsed 0:09:19, remaining 0:08:39\n",
      "sampling: iterations 2110 of 4000, elapsed 0:09:26, remaining 0:08:27\n",
      "sampling: iterations 2144 of 4000, elapsed 0:09:32, remaining 0:08:16\n",
      "sampling: iterations 2180 of 4000, elapsed 0:09:39, remaining 0:08:04\n",
      "sampling: iterations 2208 of 4000, elapsed 0:09:45, remaining 0:07:55\n",
      "sampling: iterations 2242 of 4000, elapsed 0:09:52, remaining 0:07:44\n",
      "sampling: iterations 2278 of 4000, elapsed 0:09:58, remaining 0:07:32\n",
      "sampling: iterations 2314 of 4000, elapsed 0:10:04, remaining 0:07:20\n",
      "sampling: iterations 2342 of 4000, elapsed 0:10:10, remaining 0:07:12\n",
      "sampling: iterations 2376 of 4000, elapsed 0:10:16, remaining 0:07:01\n",
      "sampling: iterations 2412 of 4000, elapsed 0:10:22, remaining 0:06:49\n",
      "sampling: iterations 2438 of 4000, elapsed 0:10:28, remaining 0:06:42\n",
      "sampling: iterations 2476 of 4000, elapsed 0:10:34, remaining 0:06:31\n",
      "sampling: iterations 2514 of 4000, elapsed 0:10:42, remaining 0:06:19\n",
      "sampling: iterations 2552 of 4000, elapsed 0:10:48, remaining 0:06:08\n",
      "sampling: iterations 2581 of 4000, elapsed 0:10:54, remaining 0:05:59\n",
      "sampling: iterations 2619 of 4000, elapsed 0:11:02, remaining 0:05:49\n",
      "sampling: iterations 2656 of 4000, elapsed 0:11:09, remaining 0:05:38\n",
      "sampling: iterations 2694 of 4000, elapsed 0:11:15, remaining 0:05:27\n",
      "sampling: iterations 2732 of 4000, elapsed 0:11:22, remaining 0:05:16\n",
      "sampling: iterations 2770 of 4000, elapsed 0:11:28, remaining 0:05:06\n",
      "sampling: iterations 2799 of 4000, elapsed 0:11:34, remaining 0:04:58\n",
      "sampling: iterations 2837 of 4000, elapsed 0:11:41, remaining 0:04:47\n",
      "sampling: iterations 2874 of 4000, elapsed 0:11:48, remaining 0:04:37\n",
      "sampling: iterations 2912 of 4000, elapsed 0:11:55, remaining 0:04:27\n",
      "sampling: iterations 2950 of 4000, elapsed 0:12:02, remaining 0:04:17\n",
      "sampling: iterations 2988 of 4000, elapsed 0:12:09, remaining 0:04:07\n",
      "sampling: iterations 3017 of 4000, elapsed 0:12:14, remaining 0:03:59\n",
      "sampling: iterations 3055 of 4000, elapsed 0:12:21, remaining 0:03:49\n",
      "sampling: iterations 3092 of 4000, elapsed 0:12:28, remaining 0:03:40\n",
      "sampling: iterations 3132 of 4000, elapsed 0:12:34, remaining 0:03:29\n",
      "sampling: iterations 3163 of 4000, elapsed 0:12:40, remaining 0:03:21\n",
      "sampling: iterations 3201 of 4000, elapsed 0:12:48, remaining 0:03:12\n",
      "sampling: iterations 3241 of 4000, elapsed 0:12:55, remaining 0:03:02\n",
      "sampling: iterations 3272 of 4000, elapsed 0:13:01, remaining 0:02:54\n",
      "sampling: iterations 3310 of 4000, elapsed 0:13:08, remaining 0:02:44\n",
      "sampling: iterations 3350 of 4000, elapsed 0:13:15, remaining 0:02:34\n",
      "sampling: iterations 3381 of 4000, elapsed 0:13:20, remaining 0:02:26\n",
      "sampling: iterations 3419 of 4000, elapsed 0:13:28, remaining 0:02:17\n",
      "sampling: iterations 3461 of 4000, elapsed 0:13:35, remaining 0:02:07\n",
      "sampling: iterations 3503 of 4000, elapsed 0:13:43, remaining 0:01:57\n",
      "sampling: iterations 3535 of 4000, elapsed 0:13:48, remaining 0:01:49\n",
      "sampling: iterations 3566 of 4000, elapsed 0:13:55, remaining 0:01:42\n",
      "sampling: iterations 3598 of 4000, elapsed 0:14:00, remaining 0:01:34\n",
      "sampling: iterations 3629 of 4000, elapsed 0:14:05, remaining 0:01:26\n",
      "sampling: iterations 3661 of 4000, elapsed 0:14:12, remaining 0:01:19\n",
      "sampling: iterations 3703 of 4000, elapsed 0:14:19, remaining 0:01:09\n",
      "sampling: iterations 3745 of 4000, elapsed 0:14:27, remaining 0:00:59\n",
      "sampling: iterations 3786 of 4000, elapsed 0:14:34, remaining 0:00:49\n",
      "sampling: iterations 3816 of 4000, elapsed 0:14:42, remaining 0:00:43\n",
      "sampling: iterations 3836 of 4000, elapsed 0:14:50, remaining 0:00:38\n",
      "sampling: iterations 3856 of 4000, elapsed 0:14:57, remaining 0:00:34\n",
      "sampling: iterations 3876 of 4000, elapsed 0:15:04, remaining 0:00:29\n",
      "sampling: iterations 3896 of 4000, elapsed 0:15:11, remaining 0:00:24\n",
      "sampling: iterations 3916 of 4000, elapsed 0:15:18, remaining 0:00:20\n",
      "sampling: iterations 3936 of 4000, elapsed 0:15:25, remaining 0:00:15\n",
      "sampling: iterations 3956 of 4000, elapsed 0:15:32, remaining 0:00:10\n",
      "sampling: iterations 3976 of 4000, elapsed 0:15:40, remaining 0:00:06\n",
      "sampling: iterations 3996 of 4000, elapsed 0:15:48, remaining 0:00:01\n",
      "sampling: iterations 4000 of 4000, elapsed 0:15:49, remaining 0:00:00\n",
      "sampling.......\n",
      "sampling: iterations 15 of 4000, elapsed 0:00:05, remaining 0:22:56\n",
      "sampling: iterations 67 of 4000, elapsed 0:00:15, remaining 0:14:52\n",
      "sampling: iterations 106 of 4000, elapsed 0:00:20, remaining 0:12:26\n",
      "sampling: iterations 145 of 4000, elapsed 0:00:29, remaining 0:12:54\n",
      "sampling: iterations 184 of 4000, elapsed 0:00:34, remaining 0:11:53\n",
      "sampling: iterations 223 of 4000, elapsed 0:00:43, remaining 0:12:03\n",
      "sampling: iterations 262 of 4000, elapsed 0:00:48, remaining 0:11:29\n",
      "sampling: iterations 301 of 4000, elapsed 0:00:57, remaining 0:11:36\n",
      "sampling: iterations 340 of 4000, elapsed 0:01:03, remaining 0:11:15\n",
      "sampling: iterations 366 of 4000, elapsed 0:01:08, remaining 0:11:14\n",
      "sampling: iterations 392 of 4000, elapsed 0:01:13, remaining 0:11:12\n",
      "sampling: iterations 431 of 4000, elapsed 0:01:21, remaining 0:11:13\n",
      "sampling: iterations 470 of 4000, elapsed 0:01:27, remaining 0:10:56\n",
      "sampling: iterations 509 of 4000, elapsed 0:01:35, remaining 0:10:51\n",
      "sampling: iterations 548 of 4000, elapsed 0:01:41, remaining 0:10:38\n",
      "sampling: iterations 587 of 4000, elapsed 0:01:48, remaining 0:10:31\n",
      "sampling: iterations 626 of 4000, elapsed 0:01:55, remaining 0:10:22\n",
      "sampling: iterations 652 of 4000, elapsed 0:02:00, remaining 0:10:18\n",
      "sampling: iterations 678 of 4000, elapsed 0:02:06, remaining 0:10:17\n",
      "sampling: iterations 704 of 4000, elapsed 0:02:11, remaining 0:10:13\n",
      "sampling: iterations 743 of 4000, elapsed 0:02:18, remaining 0:10:04\n",
      "sampling: iterations 782 of 4000, elapsed 0:02:25, remaining 0:09:57\n",
      "sampling: iterations 821 of 4000, elapsed 0:02:32, remaining 0:09:47\n",
      "sampling: iterations 860 of 4000, elapsed 0:02:39, remaining 0:09:41\n",
      "sampling: iterations 899 of 4000, elapsed 0:02:45, remaining 0:09:30\n",
      "sampling: iterations 938 of 4000, elapsed 0:02:53, remaining 0:09:25\n",
      "sampling: iterations 964 of 4000, elapsed 0:02:58, remaining 0:09:22\n",
      "sampling: iterations 990 of 4000, elapsed 0:03:03, remaining 0:09:18\n",
      "sampling: iterations 1016 of 4000, elapsed 0:03:09, remaining 0:09:14\n",
      "sampling: iterations 1055 of 4000, elapsed 0:03:15, remaining 0:09:03\n",
      "sampling: iterations 1094 of 4000, elapsed 0:03:23, remaining 0:08:59\n",
      "sampling: iterations 1133 of 4000, elapsed 0:03:28, remaining 0:08:47\n",
      "sampling: iterations 1172 of 4000, elapsed 0:03:37, remaining 0:08:43\n",
      "sampling: iterations 1211 of 4000, elapsed 0:03:42, remaining 0:08:31\n",
      "sampling: iterations 1250 of 4000, elapsed 0:03:51, remaining 0:08:28\n",
      "sampling: iterations 1276 of 4000, elapsed 0:03:56, remaining 0:08:24\n",
      "sampling: iterations 1302 of 4000, elapsed 0:04:01, remaining 0:08:20\n",
      "sampling: iterations 1328 of 4000, elapsed 0:04:06, remaining 0:08:15\n",
      "sampling: iterations 1380 of 4000, elapsed 0:04:16, remaining 0:08:05\n",
      "sampling: iterations 1419 of 4000, elapsed 0:04:21, remaining 0:07:54\n",
      "sampling: iterations 1458 of 4000, elapsed 0:04:29, remaining 0:07:49\n",
      "sampling: iterations 1497 of 4000, elapsed 0:04:35, remaining 0:07:39\n",
      "sampling: iterations 1536 of 4000, elapsed 0:04:43, remaining 0:07:34\n",
      "sampling: iterations 1575 of 4000, elapsed 0:04:49, remaining 0:07:24\n",
      "sampling: iterations 1601 of 4000, elapsed 0:04:54, remaining 0:07:20\n",
      "sampling: iterations 1627 of 4000, elapsed 0:04:59, remaining 0:07:16\n",
      "sampling: iterations 1666 of 4000, elapsed 0:05:07, remaining 0:07:10\n",
      "sampling: iterations 1705 of 4000, elapsed 0:05:14, remaining 0:07:02\n",
      "sampling: iterations 1731 of 4000, elapsed 0:05:19, remaining 0:06:58\n",
      "sampling: iterations 1757 of 4000, elapsed 0:05:24, remaining 0:06:54\n",
      "sampling: iterations 1796 of 4000, elapsed 0:05:31, remaining 0:06:46\n",
      "sampling: iterations 1835 of 4000, elapsed 0:05:38, remaining 0:06:38\n",
      "sampling: iterations 1874 of 4000, elapsed 0:05:45, remaining 0:06:31\n",
      "sampling: iterations 1913 of 4000, elapsed 0:05:52, remaining 0:06:24\n",
      "sampling: iterations 1952 of 4000, elapsed 0:05:58, remaining 0:06:16\n",
      "sampling: iterations 1991 of 4000, elapsed 0:06:06, remaining 0:06:09\n",
      "sampling: iterations 2017 of 4000, elapsed 0:06:11, remaining 0:06:05\n",
      "sampling: iterations 2043 of 4000, elapsed 0:06:16, remaining 0:06:00\n",
      "sampling: iterations 2069 of 4000, elapsed 0:06:22, remaining 0:05:56\n",
      "sampling: iterations 2108 of 4000, elapsed 0:06:28, remaining 0:05:48\n",
      "sampling: iterations 2147 of 4000, elapsed 0:06:36, remaining 0:05:41\n",
      "sampling: iterations 2186 of 4000, elapsed 0:06:41, remaining 0:05:33\n",
      "sampling: iterations 2225 of 4000, elapsed 0:06:50, remaining 0:05:27\n",
      "sampling: iterations 2264 of 4000, elapsed 0:06:55, remaining 0:05:18\n",
      "sampling: iterations 2303 of 4000, elapsed 0:07:04, remaining 0:05:13\n",
      "sampling: iterations 2329 of 4000, elapsed 0:07:10, remaining 0:05:08\n",
      "sampling: iterations 2355 of 4000, elapsed 0:07:15, remaining 0:05:04\n",
      "sampling: iterations 2394 of 4000, elapsed 0:07:20, remaining 0:04:55\n",
      "sampling: iterations 2433 of 4000, elapsed 0:07:29, remaining 0:04:49\n",
      "sampling: iterations 2472 of 4000, elapsed 0:07:34, remaining 0:04:41\n",
      "sampling: iterations 2511 of 4000, elapsed 0:07:43, remaining 0:04:34\n",
      "sampling: iterations 2550 of 4000, elapsed 0:07:48, remaining 0:04:26\n",
      "sampling: iterations 2589 of 4000, elapsed 0:07:57, remaining 0:04:20\n",
      "sampling: iterations 2615 of 4000, elapsed 0:08:02, remaining 0:04:15\n",
      "sampling: iterations 2641 of 4000, elapsed 0:08:07, remaining 0:04:11\n",
      "sampling: iterations 2667 of 4000, elapsed 0:08:12, remaining 0:04:06\n",
      "sampling: iterations 2706 of 4000, elapsed 0:08:19, remaining 0:03:58\n",
      "sampling: iterations 2745 of 4000, elapsed 0:08:26, remaining 0:03:51\n",
      "sampling: iterations 2784 of 4000, elapsed 0:08:33, remaining 0:03:44\n",
      "sampling: iterations 2823 of 4000, elapsed 0:08:40, remaining 0:03:37\n",
      "sampling: iterations 2862 of 4000, elapsed 0:08:47, remaining 0:03:29\n",
      "sampling: iterations 2901 of 4000, elapsed 0:08:54, remaining 0:03:22\n",
      "sampling: iterations 2940 of 4000, elapsed 0:09:01, remaining 0:03:15\n",
      "sampling: iterations 2966 of 4000, elapsed 0:09:07, remaining 0:03:11\n",
      "sampling: iterations 2992 of 4000, elapsed 0:09:12, remaining 0:03:06\n",
      "sampling: iterations 3031 of 4000, elapsed 0:09:18, remaining 0:02:59\n",
      "sampling: iterations 3070 of 4000, elapsed 0:09:26, remaining 0:02:51\n",
      "sampling: iterations 3109 of 4000, elapsed 0:09:32, remaining 0:02:44\n",
      "sampling: iterations 3148 of 4000, elapsed 0:09:40, remaining 0:02:37\n",
      "sampling: iterations 3187 of 4000, elapsed 0:09:46, remaining 0:02:29\n",
      "sampling: iterations 3226 of 4000, elapsed 0:09:54, remaining 0:02:23\n",
      "sampling: iterations 3252 of 4000, elapsed 0:09:59, remaining 0:02:18\n",
      "sampling: iterations 3278 of 4000, elapsed 0:10:05, remaining 0:02:13\n",
      "sampling: iterations 3317 of 4000, elapsed 0:10:10, remaining 0:02:06\n",
      "sampling: iterations 3356 of 4000, elapsed 0:10:19, remaining 0:01:59\n",
      "sampling: iterations 3382 of 4000, elapsed 0:10:24, remaining 0:01:54\n",
      "sampling: iterations 3408 of 4000, elapsed 0:10:30, remaining 0:01:49\n",
      "sampling: iterations 3460 of 4000, elapsed 0:10:39, remaining 0:01:40\n",
      "sampling: iterations 3512 of 4000, elapsed 0:10:48, remaining 0:01:30\n",
      "sampling: iterations 3564 of 4000, elapsed 0:10:57, remaining 0:01:20\n",
      "sampling: iterations 3603 of 4000, elapsed 0:11:02, remaining 0:01:13\n",
      "sampling: iterations 3642 of 4000, elapsed 0:11:11, remaining 0:01:06\n",
      "sampling: iterations 3668 of 4000, elapsed 0:11:16, remaining 0:01:01\n",
      "sampling: iterations 3694 of 4000, elapsed 0:11:21, remaining 0:00:56\n",
      "sampling: iterations 3720 of 4000, elapsed 0:11:26, remaining 0:00:52\n",
      "sampling: iterations 3759 of 4000, elapsed 0:11:32, remaining 0:00:44\n",
      "sampling: iterations 3798 of 4000, elapsed 0:11:40, remaining 0:00:37\n",
      "sampling: iterations 3837 of 4000, elapsed 0:11:46, remaining 0:00:30\n",
      "sampling: iterations 3876 of 4000, elapsed 0:11:53, remaining 0:00:23\n",
      "sampling: iterations 3915 of 4000, elapsed 0:12:00, remaining 0:00:16\n",
      "sampling: iterations 3951 of 4000, elapsed 0:12:06, remaining 0:00:09\n",
      "sampling: iterations 3977 of 4000, elapsed 0:12:15, remaining 0:00:04\n",
      "sampling: iterations 3990 of 4000, elapsed 0:12:20, remaining 0:00:02\n",
      "sampling: iterations 4000 of 4000, elapsed 0:12:24, remaining 0:00:00\n"
     ]
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "(((trace[\"flag\"].mean(axis=-1).mean(axis=-1)>0.5) == (abbrant.rg_flag+abbrant.preknowledge_flag))).mean()"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "0.9964666666666666"
      ]
     },
     "metadata": {},
     "execution_count": 9
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "((trace[\"flag\"].mean(axis=-1).mean(axis=-1)>0.5)\\\n",
    "     *(trace[\"pre_knowledge_flag\"].mean(axis=-1).mean(axis=-1)>0.5)\\\n",
    "         == (abbrant.preknowledge_flag)).mean()"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "0.969"
      ]
     },
     "metadata": {},
     "execution_count": 10
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "flag_cnt = ((trace[\"flag\"].mean(axis=-1).mean(axis=-1)>0.5)==1).sum()"
   ],
   "outputs": [],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "((((trace[\"flag\"].mean(axis=-1).mean(axis=-1)>0.5)\\\n",
    "     *(trace[\"pre_knowledge_flag\"].mean(axis=-1).mean(axis=-1)>0.5))== (abbrant.preknowledge_flag))\\\n",
    "         *(trace[\"flag\"].mean(axis=-1).mean(axis=-1)>0.5)).sum()/flag_cnt"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "0.8521351179094965"
      ]
     },
     "metadata": {},
     "execution_count": 12
    }
   ],
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "source": [
    "((trace[\"flag\"].mean(axis=-1).mean(axis=-1)>0.5)\\\n",
    "     *(1-(trace[\"pre_knowledge_flag\"].mean(axis=-1).mean(axis=-1)>0.5))\\\n",
    "         == (abbrant.rg_flag)).mean()"
   ],
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "0.9656"
      ]
     },
     "metadata": {},
     "execution_count": 13
    }
   ],
   "metadata": {}
  }
 ],
 "metadata": {
  "orig_nbformat": 4,
  "language_info": {
   "name": "python",
   "version": "3.9.5",
   "mimetype": "text/x-python",
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "pygments_lexer": "ipython3",
   "nbconvert_exporter": "python",
   "file_extension": ".py"
  },
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.9.5 64-bit ('mcmc': conda)"
  },
  "interpreter": {
   "hash": "868a26e6694496dfcf6d0346ef7ea32bca76239555a9377c505528fb572c7502"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}